package com.itheima.demo;

/**
 * @author Zhang_Han
 * @version 1.0
 * @date 2020/7/13 21:32
 */
public class Cave implements Runnable {
    Object lock = new Object();
    private int num = 1;
    int count = 0;

    @Override
    public void run() {
        synchronized (lock) {
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName() + "是第" + (num++) + "个通过");
            //System.out.println(Thread.currentThread().getName());
            System.out.println("已经通过了" + (++count) + "个人");
        }
    }
}
